# -*- coding: utf-8 -*-

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QCheckBox


class Ui_Setting_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(348, 308)
        Dialog.setMinimumSize(QtCore.QSize(348, 308))
        Dialog.setMaximumSize(QtCore.QSize(348, 308))
        Dialog.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("../ui/logo.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        Dialog.setWindowIcon(icon)
        self.groupBox = QtWidgets.QGroupBox(Dialog)
        self.groupBox.setGeometry(QtCore.QRect(9, 9, 331, 236))
        self.groupBox.setObjectName("groupBox")
        # 编号
        self.checkBox_no = QtWidgets.QCheckBox(self.groupBox)
        self.checkBox_no.setGeometry(QtCore.QRect(10, 29, 91, 19))
        self.checkBox_no.setObjectName("checkBox_no")
        self.checkBox_no.setChecked(True)
        # 字段名
        self.checkBox_coloum = QtWidgets.QCheckBox(self.groupBox)
        self.checkBox_coloum.setObjectName("checkBox_coloum")
        self.checkBox_coloum.setGeometry(QtCore.QRect(10, 58, 91, 19))
        self.checkBox_coloum.setChecked(True)
        self.checkBox_coloum.setDisabled(True)
        # 字段类型
        self.checkBox_type = QtWidgets.QCheckBox(self.groupBox)
        self.checkBox_type.setGeometry(QtCore.QRect(10, 87, 91, 19))
        self.checkBox_type.setObjectName("checkBox_type")
        self.checkBox_type.setChecked(True)
        # 字段长度
        self.checkBox_length = QtWidgets.QCheckBox(self.groupBox)
        self.checkBox_length.setGeometry(QtCore.QRect(10, 116, 91, 19))
        self.checkBox_length.setObjectName("checkBox_length")
        self.checkBox_length.setChecked(True)
        # 是否主键
        self.checkBox_isPri = QtWidgets.QCheckBox(self.groupBox)
        self.checkBox_isPri.setGeometry(QtCore.QRect(10, 145, 111, 19))
        self.checkBox_isPri.setObjectName("checkBox_isPri")
        self.checkBox_isPri.setChecked(True)
        # 是否为空
        self.checkBox_isNull = QtWidgets.QCheckBox(self.groupBox)
        self.checkBox_isNull.setGeometry(QtCore.QRect(10, 174, 101, 19))
        self.checkBox_isNull.setObjectName("checkBox_isNull")
        self.checkBox_isNull.setChecked(True)
        # 默认值
        self.checkBox_defVlaue = QtWidgets.QCheckBox(self.groupBox)
        self.checkBox_defVlaue.setGeometry(QtCore.QRect(120, 30, 91, 19))
        self.checkBox_defVlaue.setObjectName("checkBox_defVlaue")
        self.checkBox_defVlaue.setChecked(True)
        # 说明
        self.checkBox_remark = QtWidgets.QCheckBox(self.groupBox)
        self.checkBox_remark.setGeometry(QtCore.QRect(120, 60, 91, 19))
        self.checkBox_remark.setObjectName("checkBox_remark")
        self.checkBox_remark.setChecked(True)

        self.horizontalLayoutWidget = QtWidgets.QWidget(Dialog)
        self.horizontalLayoutWidget.setGeometry(QtCore.QRect(140, 250, 194, 51))
        self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget)
        self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.selectAll = QtWidgets.QPushButton(self.horizontalLayoutWidget)
        self.selectAll.setObjectName("selectAll")
        self.selectAll.clicked.connect(self.checkedAll)
        self.horizontalLayout_2.addWidget(self.selectAll)
        self.saveButton = QtWidgets.QPushButton(self.horizontalLayoutWidget)
        self.saveButton.setObjectName("saveButton")
        self.horizontalLayout_2.addWidget(self.saveButton)

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "模板设置"))
        self.groupBox.setTitle(_translate("Dialog", "选择要显示字段"))
        self.checkBox_no.setText(_translate("Dialog", "编号"))
        self.checkBox_type.setText(_translate("Dialog", "字段类型"))
        self.checkBox_coloum.setText(_translate("Dialog", "字段名"))
        self.checkBox_length.setText(_translate("Dialog", "长度"))
        self.checkBox_isPri.setText(_translate("Dialog", "是否是主键"))
        self.checkBox_isNull.setText(_translate("Dialog", "是否为空"))
        self.checkBox_defVlaue.setText(_translate("Dialog", "默认值"))
        self.checkBox_remark.setText(_translate("Dialog", "说明"))
        self.selectAll.setText(_translate("Dialog", "全选"))
        self.saveButton.setText(_translate("Dialog", "保存"))

    def checkedAll(self):
        children = self.groupBox.children()
        for child in children:
            if isinstance(child, QCheckBox):
                child.setChecked(True)
                # print (child.objectName())